package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.appwoo.txtws.adapter.ListViewCreator;
import com.appwoo.txtws.adapter.Page;
import com.appwoo.txtws.adapter.SimpleListAdapter;
import com.appwoo.txtws.app.App;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.RecomSoftServer;
import com.appwoo.txtws.wheel.widget.PageListView;
import com.appwoo.txtws.wheel.widget.PageListView.OnRefreshListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SysAppActivity extends AppActivity
  implements AdapterView.OnItemClickListener
{
  private static AutoSoftInfo asi;
  private SimpleListAdapter<AutoSoftInfo> adapter;
  private StateBean bean = new StateBean();
  private boolean blDataTask = false;
  private Button btnCurrent;
  private CheckBox cbCurrent;
  private ProgressDialog dialog = null;
  private List<AutoSoftInfo> events;
  private int grantflag = 0;
  private Boolean isFoot = Boolean.valueOf(false);
  private int isHot = 1;
  private Boolean isSDCard = Boolean.valueOf(false);
  private PageListView lvList;
  private Map<String, Integer> maplist;
  private Page<AutoSoftInfo> page = new Page();
  private String softid = "";
  private TextView tvSave;

  private void initView()
  {
    this.isSDCard = Boolean.valueOf(Global.isSDCard());
    this.maplist = new HashMap();
    this.tvSave = ((TextView)findViewById(2131493019));
    this.tvSave.setVisibility(0);
    this.tvSave.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        if (SysAppActivity.this.maplist.size() > 0)
        {
          new SysAppActivity.DataTask(SysAppActivity.this).execute(new String[] { "grantflag" });
          return;
        }
        SysAppActivity.this.alertMessage("没有待提交数据。");
      }
    });
    this.lvList = ((PageListView)findViewById(2131492985));
    this.adapter = new SimpleListAdapter(this.page.getEntries(), new ListViewCreator()
    {
      public View createView(final AutoSoftInfo paramAnonymousAutoSoftInfo, View paramAnonymousView, int paramAnonymousInt)
      {
        if (paramAnonymousView == null)
          paramAnonymousView = App.getLayoutInflater().inflate(2130903119, null);
        ImageView localImageView = (ImageView)paramAnonymousView.findViewById(2131493154);
        TextView localTextView = (TextView)paramAnonymousView.findViewById(2131493155);
        CheckBox localCheckBox = (CheckBox)paramAnonymousView.findViewById(2131493011);
        localCheckBox.setOnCheckedChangeListener(null);
        localTextView.setText(paramAnonymousAutoSoftInfo.getAsname());
        if (paramAnonymousAutoSoftInfo.getIsPrecd() == 0)
          localCheckBox.setChecked(false);
        while (true)
        {
          SysAppActivity.this.loadLogoImage(localImageView, paramAnonymousAutoSoftInfo.getAdicon(), SysAppActivity.this.isSDCard);
          localCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
          {
            public void onCheckedChanged(CompoundButton paramAnonymous2CompoundButton, boolean paramAnonymous2Boolean)
            {
              AutoSoftInfo localAutoSoftInfo = paramAnonymousAutoSoftInfo;
              if (paramAnonymousAutoSoftInfo.getIsPrecd() == 0);
              for (int i = 1; ; i = 0)
              {
                localAutoSoftInfo.setIsPrecd(i);
                SysAppActivity.asi = paramAnonymousAutoSoftInfo;
                if (SysAppActivity.this.maplist.containsKey(paramAnonymousAutoSoftInfo.getKeyID()))
                  SysAppActivity.this.maplist.remove(paramAnonymousAutoSoftInfo.getKeyID());
                SysAppActivity.this.maplist.put(paramAnonymousAutoSoftInfo.getKeyID(), Integer.valueOf(SysAppActivity.asi.getIsPrecd()));
                SysAppActivity.this.adapter.notifyDataSetChanged();
                return;
              }
            }
          });
          return paramAnonymousView;
          localCheckBox.setChecked(true);
        }
      }
    });
    this.lvList.setAdapter(this.adapter);
    this.lvList.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()) && (!SysAppActivity.this.lvList.getIsNoMore()) && (SysAppActivity.this.blDataTask))
        {
          SysAppActivity.this.lvList.prepareForRefreshMore();
          SysAppActivity.this.isFoot = Boolean.valueOf(true);
          SysAppActivity.this.loadingData(false);
        }
      }
    });
    this.lvList.setOnLoadMoreListener(new PageListView.OnRefreshListener()
    {
      public void onRefresh()
      {
        SysAppActivity.this.lvList.prepareForRefreshMore();
        SysAppActivity.this.isFoot = Boolean.valueOf(true);
        SysAppActivity.this.loadingData(true);
      }
    });
    addOperation(new DataTask().execute(new String[] { "installindex" }));
  }

  private void loadingData(boolean paramBoolean)
  {
    if (paramBoolean)
      this.page.firstPage();
    while (true)
    {
      addOperation(new DataTask().execute(new String[] { "installindex" }));
      return;
      this.page.nextPage();
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903148);
    initView();
  }

  public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
  {
  }

  protected void onResume()
  {
    super.onResume();
  }

  class DataTask extends AsyncTask<String, Integer, String>
  {
    String param;

    DataTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.param = paramArrayOfString[0];
      RqSP localRqSP = new RqSP();
      String str1 = localRqSP.getLgDevAccount(SysAppActivity.this);
      String str2 = localRqSP.getLgDevId(SysAppActivity.this);
      if (this.param.equals("installindex"))
        SysAppActivity.this.events = new RecomSoftServer(SysAppActivity.this).installSoftWare(0, "", "", 1, 0, SysAppActivity.this.page.getPageNo(), SysAppActivity.this.page.getPageSize());
      while (!this.param.equals("grantflag"))
        return null;
      SysAppActivity.this.bean = new RecomSoftServer(SysAppActivity.this).updateRecd(SysAppActivity.this.maplist, str1, str2);
      return SysAppActivity.this.bean.getDesc();
    }

    protected void onPostExecute(String paramString)
    {
      if (this.param.equals("installindex"))
        if ((SysAppActivity.this.events != null) && (SysAppActivity.this.events.size() > 0))
        {
          SysAppActivity.this.page.addAllEntries(SysAppActivity.this.events);
          SysAppActivity.this.adapter.notifyDataSetChanged();
          SysAppActivity.this.lvList.onLoadMoreComplete();
          if (SysAppActivity.this.events.size() < SysAppActivity.this.page.getPageSize())
          {
            SysAppActivity.this.lvList.hideFotterMoreView();
            SysAppActivity.this.lvList.setIsNoMore(true);
          }
          SysAppActivity.this.events.clear();
          SysAppActivity.this.blDataTask = true;
        }
      while (true)
      {
        if (!SysAppActivity.this.isFoot.booleanValue())
        {
          SysAppActivity.this.closeProgress();
          SysAppActivity.this.isFoot = Boolean.valueOf(false);
        }
        super.onPostExecute(paramString);
        return;
        SysAppActivity.this.lvList.hideFotterMoreView();
        SysAppActivity.this.lvList.setIsNoMore(true);
        break;
        if (this.param.equals("grantflag"))
          if ("0".equals(SysAppActivity.this.bean.getCode()))
          {
            SysAppActivity.this.maplist.clear();
            SysAppActivity.this.alertMessage(SysAppActivity.this.getResources().getString(2131427527));
          }
          else
          {
            SysAppActivity.this.alertMessage(SysAppActivity.this.getResources().getString(2131427528));
          }
      }
    }

    protected void onPreExecute()
    {
      SysAppActivity.this.blDataTask = false;
      if (!SysAppActivity.this.isFoot.booleanValue())
        SysAppActivity.this.showProgress("");
      super.onPreExecute();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.SysAppActivity
 * JD-Core Version:    0.6.2
 */